<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <button-counter></button-counter>
        <button-counter></button-counter>
        <hello-world></hello-world>
        <!-- 使用下面的驼峰式，或报错 -->
        <HelloWorld></HelloWorld>   
        <!-- 局部组件 -->
        <test-com></test-com>
    </div>
    <test-com></test-com>   <!-- 报错 -->
    <script src="../../js/vue.js"></script>
    <script>
        Vue.component("HelloWorld", {
            data () {
                return {
                    msg: 'helloworld---'
                }
            },
            template: '<span>{{msg}}</span>'
        })        
        Vue.component("button-counter", {
            data() {
                return {
                    count: 0
                }
            },
            // template: '<button @click="count++">点击了{{count}}次</button>'
            // template: '<button @click="handel">点击了{{count}}次</button>',
            template: `
                <div>
                    <button @click="handel">点击了{{count}}次</button>
                    <span>{{count}}</span>
                    <hello-world></hello-world>
                    <HelloWorld></HelloWorld>
                </div>
            `,
            methods: {
                handel() {
                    this.count += 2
                }
            }
        })
        var testCom = {
            template: '<span>test~~~~~</span>',
        }
        var vm = new Vue({
            el: "#app",
            components: {
                "test-com": testCom
            }
        })
        

    </script>
</body>

</html>